#pragma once
#include "SeedBlock.h"
#include "Entity.h"
#include "BlockRenderer.h"
#include <map>
#include <vector>
#include "Chunk.h"
#include "Timer.h"
typedef std::map<int, Chunk*> ChunkInnerMap;
typedef std::map< int, ChunkInnerMap > ChunkMap;
#define CHUNK_UPDATE_TIME_MS 2000
class ChunkManager
{
public:
	ChunkManager(void);
	~ChunkManager(void);
	bool Initialize(Entity *pViewerEntity, uint chunkViewDist = 32);
	void Update();
	//Defines a rectangle area in which to load chunks around player
	Rect GetPlayerLoadRectangle();
	void UpdateChunkCache();
private:
	void UnloadChunkAt();
private:
	CTimer m_chunkUpdateTimer;
	bool m_bForcedChunkUpdate;
	uint m_nChunkViewRange;
	Entity *m_pViewerEntity;
	ChunkMap m_chunkMap;
	std::vector<Chunk*> m_chunksToDraw;
};

